package Week5;

import java.util.*;

public class Day28 {
}

//牛客:游的重组偶数
class Main9 {
    public static void Swap(char[] s, int i, int j) {
        char tmp = s[i];
        s[i] = s[j];
        s[j] = tmp;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while (q-- != 0) {
            char[] s = in.next().toCharArray();
            int n = s.length;
            for (int i = n - 1; i >= 0; i--) {
                if ((s[i] - '0') % 2 == 0) {
                    Swap(s, i, n - 1);
                    break;
                }
            }
            if ((s[n - 1] - '0') % 2 == 0) {
                System.out.println(s);
            } else {
                System.out.println(-1);
            }
        }
    }
}

//牛客:体操队形
class Main10 {
    public static int N = 15;
    public static int n, ret;
    public static boolean[] visits = new boolean[N];
    public static int[] arr = new int[N];
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 1; i <= n; i++){
            arr[i] = in.nextInt();
        }
        dfs(1);
        System.out.println(ret);
    }

    public static void dfs(int pos){
        if(pos == n + 1){
            ret++;
            return;
        }

        for(int i = 1; i <= n; i++){
            if(visits[i] == true) continue;
            if(visits[arr[i]]) return;
            visits[i] = true;
            dfs(pos + 1);
            visits[i] = false;
        }
    }
}

//牛客:NC6 二叉树中的最大路径和
class Solution3 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param root TreeNode类
     * @return int整型
     */
    public int ret = -1010;
    public int maxPathSum (TreeNode root) {
        // write code here
        dfs(root);
        return ret;
    }

    public int dfs(TreeNode root){
        if(root == null) return 0;

        int l = Math.max(0 , dfs(root.left));
        int r = Math.max(0 , dfs(root.right));
        ret = Math.max(ret , root.val + l + r);

        return root.val + Math.max(l , r);
    }
}